import { LoginTypes } from "redux/constants";

const initialState = {
  loading: false,
  error: null,
};

export default function (state = initialState, action) {
  switch (action.type) {
    case LoginTypes.GET_REQUEST:
      return { ...state, loading: true, error: null };
    case LoginTypes.GET_SUCCESS:
      return { loading: false, error: null };
    case LoginTypes.GET_FAILURE:
      return {
        ...state,
        loading: false,
        error: action.payload,
      };
    default:
      return state;
  }
}
